package websocketgulu.demo.common.lang;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class Result {
    private String code;

    private String msg;

    private Object data;

    public static websocketgulu.demo.common.lang.Result success(Object data) {
        return success("200", "successful", data);
    }

    public static websocketgulu.demo.common.lang.Result success(String code, String msg, Object data) {
        websocketgulu.demo.common.lang.Result res = new websocketgulu.demo.common.lang.Result();
        res.setCode(code);
        res.setMsg(msg);
        res.setData(data);
        return res;
    }

    public static websocketgulu.demo.common.lang.Result fail(String msg) {
        return fail("400", msg, null);
    }

    public static websocketgulu.demo.common.lang.Result fail(String msg, Object data) {
        return fail("400", msg, data);
    }

    public static websocketgulu.demo.common.lang.Result fail(String code, String msg, Object data) {
        websocketgulu.demo.common.lang.Result res = new websocketgulu.demo.common.lang.Result();
        res.setCode(code);
        res.setMsg(msg);
        res.setData(data);
        return res;
    }
}
